package top.lightHearted.socket;

import org.kurento.client.KurentoClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;

/**
 * WebSocketConfig class
 *
 * @author gpf
 * @date 2018/03/23
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer{

    protected static final Logger logger = LoggerFactory.getLogger(WebSocketConfig.class);

    @Autowired
    private KurentoHandler kurentoHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        //registry.addHandler(webRTCHandler, "/systemHandle").setAllowedOrigins("*");
        registry.addHandler(kurentoHandler, "/kurentoHandle").setAllowedOrigins("*");
    }

    @Bean
    public KurentoClient kurentoClient() {
        return KurentoClient.create("ws://47.104.137.175:8888/kurento");
    }


}
